//
// Created by Zemon on 2024/11/3.
//

#include "railway.h"
#include "remote_control.h"
#include "main.h"
extern TIM_HandleTypeDef htim8;
extern RC_ctrl_t rc_ctrl;
int16_t angle_delta3;
int16_t angle_now3 = 800;

void railway_init(void){
    __HAL_TIM_SetCompare(&htim8,TIM_CHANNEL_3,800);
}

void railway_control(void){
    angle_delta3 = rc_ctrl.rc.ch[1]/66;
    angle_now3 = angle_now3 + angle_delta3;
    if (angle_now3<=400)
        angle_now3 = 400;
    else if(angle_now3>=1100)
        angle_now3 = 1100;
    else
        angle_now3 = angle_now3;
            __HAL_TIM_SetCompare(&htim8,TIM_CHANNEL_3,angle_now3);
}